<?php
/**
 * @package		Joomla.Site
 * @subpackage	com_search
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
?>

<dl class="search-results<?php echo $this->pageclass_sfx; ?>">
<?php foreach($this->results as $result) : ?>
	<dt class="result-title">
		<?php echo $this->pagination->limitstart + $result->count.'. ';?>
		<?php if ($result->href) :?>
			<a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) :?> target="_blank"<?php endif;?>>
				<?php echo $this->escape($result->title);?>
			</a>
		<?php else:?>
			<?php echo $this->escape($result->title);?>
		<?php endif; ?>
	</dt>
	<?php if ($result->section) : ?>
		<dd class="result-category">
        
        
        <?php
		$url = parse_url($result->href);
		$keys = array(); 
		parse_str(isset($url['query']) ? $url['query'] : '', $keys );
		
		if( isset( $keys['option'] ) ) {
			if( JFile::exists( JPATH_SITE . DS . 'templates' . DS . JFactory::getApplication()->getTemplate() . DS . "images" . DS . 'icon_searchresult_'.strip_tags($keys['option']).'_dark.png' )				){
		?>
        	<?php echo '<div class="icon_searchresult_'.strip_tags($keys['option']).'">'.$this->escape($result->section).'</div>'; ?>
        <?php  	
			} else {
		?>
        	<?php echo '<div class="icon_searchresult_blank">'.$this->escape($result->section).'</div>'; ?>
        <?php		
			}
		} else {
		?>
        	<?php echo '<div class="icon_searchresult_blank">'.$this->escape($result->section).'</div>'; ?>
        <?php
		}
		?>
        

		</dd>
	<?php endif; ?>
	<dd class="result-text">
		<?php echo $result->text; ?>
	</dd>
	<?php if ($this->params->get('show_date')) : ?>
		<dd class="result-created<?php echo $this->pageclass_sfx; ?>">
			<?php echo JText::sprintf('JGLOBAL_CREATED_DATE_ON', $result->created); ?>
		</dd>
	<?php endif; ?>
<?php endforeach; ?>
</dl>

<div class="pagination">
	<?php echo $this->pagination->getPagesLinks(); ?>
</div>
